package com.simons.common.utils.file.txt;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.io.IOUtils;

import com.simons.common.utils.file.CommonStreamUtil;

public class PropUtil {
	
	private PropUtil(){
		// Do nothing because of 不能创建对象
	}

	public static Properties getProperties(String propName, Class<?> clazz) throws IOException{
		InputStream in = null;
		Properties prop = null;
		try{
			prop = new Properties();
			in = CommonStreamUtil.getInputStream(propName);
			if(in == null){
				return null;
			}
			prop.load(in);
			return prop;
		}finally{
			IOUtils.closeQuietly(in);
		}
	}
	
	public static Properties getProperties(InputStream in) throws IOException{
		Properties prop = null;
		try{
			prop = new Properties();
			prop.load(in);
			return prop;
		}finally{
			IOUtils.closeQuietly(in);
		}
	}
	
}
